<?php
require_once('../../config.php');
require_once('security.php');

	global $pagetitle,$filetitle;
    // Create the variable for ThisPage2
    $thispage2 = trim($filetitle);
    // Strip out hyphens for page variable
    $thispage3 = str_replace("-", "", $thispage2);
    // Make lowercase and trim whitespace at ends
    $thispage3 = trim(strtolower($thispage3));

    // Create the link text
    $linktext2 = $pagetitle;
    // Trim whitespace at ends
    $linktext2 = trim($linktext2);
    

    // Define the HTML for a button in menu.php (as class template)
    //TG 19/7/09
    $button = '<?php $' . $thispage3 . ' = new Button;'. ' $' . $thispage3 . '->ThisPage = $le_page;' . '$' . $thispage3 . '->ThisPage2 = "' . $thispage2 . '";' .'$' . $thispage3 . '->LinkText = "' . $linktext2 . '";' . '$' . $thispage3 . '->basePath = "$wwwroot";' .'$' . $thispage3 . '->Template2();' .'?>' ."\n"; 

//    $button = $buttonHTML . "\n";

    // Path to the .php file (to write the template)
    $filename = "../includes/menu.php";

    // Write the contents
    $fp = fopen($filename, "a") or die("Couldn't open $filename.");
    fwrite($fp, $button);
    fclose($fp);

    // Feedback
    $response = "A Link has been added to the menu (file: menu.php).";

?>
